package com.kaola.kaistory.utils;

import com.kaola.kaistory.activity.App;
import com.kaola.kaistory.core.ex.NotInMainThreadError;
import com.kaola.kaistory.core.ex.ObserverDismatchError;
import com.kaola.kaistory.core.msg.IObserverBase;
import com.kaola.kaistory.core.msg.MessageID;

public class Debug {

	private Debug() {
	}
	public static void checkThread(String methodName) {
		if(Thread.currentThread().getId() != App.getMainThreadID()){
			throw new NotInMainThreadError(methodName + "必须在主线程调用而实际在"+Thread.currentThread()+"被调用");
		}
	}
	
	public static void checkType(MessageID id, IObserverBase observer){
		if(!id.getObserverClass().isInstance(observer)){
			throw new ObserverDismatchError("消息所需要的类型是" +id.getObserverClass()+" 而传入的是"+(observer==null?null:observer.getClass()));
		}
	}
}
